package net.lab1024.sa.admin.module.business.school.floor.controller;

import net.lab1024.sa.admin.module.business.school.floor.domain.form.FloorAddForm;
import net.lab1024.sa.admin.module.business.school.floor.domain.form.FloorQueryForm;
import net.lab1024.sa.admin.module.business.school.floor.domain.form.FloorUpdateForm;
import net.lab1024.sa.admin.module.business.school.floor.domain.vo.FloorVO;
import net.lab1024.sa.admin.module.business.school.floor.service.FloorService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 楼层 Controller
 *
 * @Author ZouYang
 * @Date 2024-12-28 12:10:44
 * @Copyright ZouYang
 */

@RestController
@Tag(name = "楼层")
public class FloorController {

    @Resource
    private FloorService floorService;

    @Operation(summary = "分页查询 @author ZouYang")
    @PostMapping("/floor/queryPage")
    @SaCheckPermission("floor:query")
    public ResponseDTO<PageResult<FloorVO>> queryPage(@RequestBody @Valid FloorQueryForm queryForm) {
        return ResponseDTO.ok(floorService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author ZouYang")
    @PostMapping("/floor/add")
    @SaCheckPermission("floor:add")
    public ResponseDTO<String> add(@RequestBody @Valid FloorAddForm addForm) {
        return floorService.add(addForm);
    }

    @Operation(summary = "更新 @author ZouYang")
    @PostMapping("/floor/update")
    @SaCheckPermission("floor:update")
    public ResponseDTO<String> update(@RequestBody @Valid FloorUpdateForm updateForm) {
        return floorService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author ZouYang")
    @PostMapping("/floor/batchDelete")
    @SaCheckPermission("floor:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return floorService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author ZouYang")
    @GetMapping("/floor/delete/{id}")
    @SaCheckPermission("floor:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return floorService.delete(id);
    }
}
